import os
from os import path
from distutils.core import setup, Extension

def compiler(): 
    return '-gcc43' if os.name=='posix' else '-mgw34'
def debug():
    return '-d'
def threads():
    return '-mt'
def version():
    return ''
def boostformat(lib, compiler=compiler(), threads=threads(), debug=debug(), version=version()):
    return 'boost_%(lib)s%(compiler)s%(threads)s%(debug)s%(version)s' % locals()
    
device=None
if os.name == 'posix':
    boost='/home/ip/work/boost-trunk'
    device = Extension('device', ['PythonInterface.cpp'],
         depends=['PythonInterface.cpp', 'Device.h', 'Pendant.h'],
         define_macros=[('DEBUG',None)],
         undef_macros=['NDEBUG'],
         libraries=[boostformat('system'), boostformat('python'), boostformat('thread'), 'pthread'],
         include_dirs=[boost],
         library_dirs=[path.join(boost,'stage','lib')],
         runtime_library_dirs=[path.join(boost,'stage','lib')])
else:
    assert(os.name=='nt')
    boost="C:\\Documents and Settings\\David\\boost_1_39_0"
    python="C:\\Python25"
    device = Extension('device', ['PythonInterface.cpp'],
        depends=['PythonInterface.cpp', 'Device.h', 'Pendant.h', 'SignalProcessing.h'],
        define_macros=[('_WIN32_WINNT','0x501') ],
        undef_macros=['NDEBUG'],
        libraries=[boostformat('system'), boostformat('thread'), boostformat('python'), 'fftw3', 'ws2_32'],
        include_dirs=[boost, 
                      path.join(python,'Lib','site-packages','numpy-1.2.1n1-py2.5-win32.egg','numpy','core','include'),
                      path.join(boost, '..','fftw-3.2.1','api')], 
        library_dirs=[path.join(boost,'stage','lib'),
                      path.join(boost,'..','fftw-3.2.1', '.libs')],
        extra_compile_args=['-g','-DEBUG'],
        extra_link_args=['-g','-DEBUG'])

description="""
A package for talking to biofeedback devices, at the moment supporting only the pocket neurobics pendant EEG
"""
setup (name = 'device',
        version = '0.0',
        description = description,
        ext_modules = [device])
